const BaseConfig = require("./webpack.base.config");
const merge = require("webpack-merge");
const webpack = require("webpack");
const nodeExternals = require("webpack-node-externals");
// 添加客服端热更新
Object.keys(BaseConfig.entry).forEach(T => {
    BaseConfig.entry[T] = ["webpack-hot-middleware/client?path=/__webpack_hmr&timeout=10000&reload=true"].concat(BaseConfig.entry[T]);
});

module.exports = merge(BaseConfig, {
    // mode:"development",
    module:{
        rules:[
            {
                test: /\.css$/,
                loaders: ["style-loader", "css-loader", "postcss-loader"],
            },
            {
                test: /\.scss$/,
                use: [{
                    loader: "style-loader" // 将 JS 字符串生成为 style 节点
                }, {
                    loader: "css-loader",
                    options: {
                        sourceMap: false,
                    }// 将 CSS 转化成 CommonJS 模块
                }, {
                    loader: "sass-loader",
                    options: {
                        sourceMap: false
                    }
                    // 将 Sass 编译成 CSS
                }]
            }
        ]
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoEmitOnErrorsPlugin(),
    ]
});
